//package cn.the.angry.tests;
//
//import java.awt.Color;
//import java.awt.Graphics;
//import java.awt.Graphics2D;
//import java.awt.GraphicsDevice;
//import java.awt.GraphicsEnvironment;
//import java.awt.RenderingHints;
//import java.awt.image.BufferedImage;
//
//import javax.swing.JFrame;
//import javax.swing.JPanel;
//
//import cn.the.angry.anim.Animation;
//import cn.the.angry.anim.DamageableObject;
//import cn.the.angry.resourcemanager.ResourceManager;
//import cn.the.angry.util.GraphicUtils;
//
//public class SpriteTest extends JFrame{        
//        //全屏所需
//        private final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
//        private final GraphicsDevice gd = ge.getDefaultScreenDevice();
//        
//        private static int WIDTH;
//        private static int HEIGHT;
//        private final Animation anim = new Animation(ResourceManager.getMustachePigImages());
//        private final DamageableObject ball1 = new DamageableObject(ResourceManager.getMiddleWoodBallImages());
//        private final DamageableObject square1 = new DamageableObject(ResourceManager.getMiddleWoodSquareImages());
//        private final DamageableObject rectangle1 = new DamageableObject(ResourceManager.getMiddleWoodRectangleImages());
//        private final DamageableObject batten1 = new DamageableObject(ResourceManager.getShortWoodBattenImages());
//        private final DamageableObject square2 = new DamageableObject(ResourceManager.getSmallWoodSquareImages());
//        private final DamageableObject ball2 = new DamageableObject(ResourceManager.getLargeWoodBallImages());
//        
//        public SpriteTest(){
//                super("SpriteTest");
//                //this.setSize(new Dimension(WIDTH, HEIGHT));
//                this.setTitle("SplashScreen");
//                this.setResizable(false);
//                this.setLocationRelativeTo(null);
//                this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//                this.setUndecorated(true);
//                gd.setFullScreenWindow(this);   //全屏
//                WIDTH = this.getWidth();
//                HEIGHT = this.getHeight();
//                getContentPane().add(getBackgroundCanvas());
//        }
//        
//        private JPanel getBackgroundCanvas(){
//                return new JPanel(){
//                	
//                	//为了测试旋转
//                    private float angle = 0;
//                    
//                        @Override
//                        public void paint(Graphics g)   {
//                        		
//                                Graphics2D g2 = (Graphics2D)g;
//                                g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
//                                //g2.clearRect(0, SpriteTest.HEIGHT-200-anim.getImage().getHeight(null), anim.getImage().getWidth(null), anim.getImage().getHeight(null));
////                              g2.clearRect(0, 0, anim.getImage().getWidth(null), anim.getImage().getHeight(null));
////                              g2.drawImage(
////                              g2.drawImage(ResourceManager.getSkyImage(), 0, 0, SpriteTest.WIDTH, SpriteTest.HEIGHT,  null);
//                                
//                                
//                                //蓝天
////                              GraphicUtils.autoFill(g2, (BufferedImage)ResourceManager.getSkyImage()
////                                                 , 0, 0, SpriteTest.WIDTH, SpriteTest.HEIGHT, GraphicUtils.AUTOFILLHORIZONTAL);
//                                
//                                /*g2.drawImage(ResourceManager.getSkyImage(), 0, 0, SpriteTest.HEIGHT
//                                                        , ResourceManager.getSkyImage().getWidth(null), null);*/
//                                
//                                //final Color oldColor=g2.getColor();
//                                g2.setColor(new Color(146, 204, 222));
//                                g2.fillRect(0, 0, SpriteTest.WIDTH, SpriteTest.HEIGHT-318-200);
//                                //g2.setColor(oldColor);
//                                
//                                GraphicUtils.autoFill(g2, (BufferedImage) ResourceManager.getSkyImage()
//                                        , 0, SpriteTest.HEIGHT-318-200, SpriteTest.WIDTH, SpriteTest.HEIGHT
//                                        , GraphicUtils.AUTOFILLHORIZONTAL);
//                                
//                                //树
//                                GraphicUtils.autoFill(g2, (BufferedImage) ResourceManager.getParallaxBackgroundImage()
//                                                   , 0, SpriteTest.HEIGHT-400, SpriteTest.WIDTH, SpriteTest.HEIGHT
//                                                   , GraphicUtils.AUTOFILLHORIZONTAL);
//                                
//                                //杂草
//                                GraphicUtils.autoFill(g2, (BufferedImage) ResourceManager.getParallaxGrassImage()
//                                                   , 0, SpriteTest.HEIGHT-260, SpriteTest.WIDTH, SpriteTest.HEIGHT
//                                                   , GraphicUtils.AUTOFILLHORIZONTAL);
//                                //弹弓
//                                g2.drawImage(ResourceManager.getSlingshotImage(),200,SpriteTest.HEIGHT-200-ResourceManager.getSlingshotImage().getHeight(null)/2,
//                                		ResourceManager.getSlingshotImage().getWidth(null)/2,ResourceManager.getSlingshotImage().getHeight(null)/2,null);
//                                /*动态物体，受物理引擎控制的物体*/
//                                
//                                g2.drawImage(ResourceManager.getGroundMaterialImage(), 800, SpriteTest.HEIGHT-200-ResourceManager.getGroundMaterialImage().getHeight(null)/4, 
//                                		ResourceManager.getGroundMaterialImage().getWidth(null)/2, ResourceManager.getGroundMaterialImage().getHeight(null)/4, null);                          
//                                
//                                g2.drawImage(ball1.getImage(), 800+ResourceManager.getGroundMaterialImage().getWidth(null)/4-ball1.getFrameWidth()/2, SpriteTest.HEIGHT-200-ResourceManager.getGroundMaterialImage().getHeight(null)/4-ball1.getFrameHeight(), 
//                                		null);
//                                
//                                g2.drawImage(square1.getImage(), 1100, SpriteTest.HEIGHT-200-square1.getFrameHeight(), 
//                                		null);
//                                
//                                g2.drawImage(rectangle1.getImage(), 1100, SpriteTest.HEIGHT-200-square1.getFrameHeight()-rectangle1.getFrameHeight(), 
//                                		null);
//                                
//                                g2.drawImage(batten1.getImage(), 1100-square1.getFrameWidth()/2, SpriteTest.HEIGHT-200-square1.getFrameHeight()-rectangle1.getFrameHeight()-batten1.getFrameHeight(), 
//                                		null);
//                                
//                                g2.drawImage(square2.getImage(), 1100+square1.getFrameWidth()/2-square2.getFrameWidth()/2, SpriteTest.HEIGHT-200-square1.getFrameHeight()-rectangle1.getFrameHeight()-batten1.getFrameHeight()-square2.getFrameHeight(),
//                                		null);
//                                
//                                g2.drawImage(ball2.getImage(), 1100+square1.getFrameWidth()/2-ball2.getFrameWidth()/2, SpriteTest.HEIGHT-200-square1.getFrameHeight()-rectangle1.getFrameHeight()-batten1.getFrameHeight()-square2.getFrameHeight()-ball2.getFrameHeight(),
//                                		null);
//                                
//                                /*动态物体，受物理引擎控制的物体*/                            
//                                //草坪
//                                GraphicUtils.autoFill(g2, (BufferedImage) ResourceManager.getParallaxGreenGroundImage()
//                                                   , 0, SpriteTest.HEIGHT-230, SpriteTest.WIDTH, SpriteTest.HEIGHT
//                                                   , GraphicUtils.AUTOFILLHORIZONTAL);
//                                
//                                
//                                //大地
//                                GraphicUtils.autoFill(g2, (BufferedImage) ResourceManager.getGroundImage()
//                                                   , 0, SpriteTest.HEIGHT-200
//                                                   , SpriteTest.WIDTH, SpriteTest.HEIGHT
//                                                   , GraphicUtils.AUTOFILLHORIZONTAL);
//                                
//                                
//                                
//                               // g2.drawImage(anim.getImage(), 0, SpriteTest.HEIGHT-200-anim.getFrameHeight(), null);
//                                
//                                BufferedImage img = GraphicUtils.rotateImage((BufferedImage) anim.getImage(), anim.getFrameWidth(), anim.getFrameHeight(), angle);
//                                angle = 10f;
//                                g2.drawImage(img, 0, SpriteTest.HEIGHT-200-img.getHeight(null), null);
//                                g2.dispose();
//                        }
//               };
//    }
//    
//    public static void main(String[] args) {
//        final SpriteTest main = new SpriteTest();
//        main.setVisible(true);
//        new Thread(new Runnable(){
//            
//            @Override
//            public void run(){
//                int count = 100;
//                while(count != 0){
//                    count--;
//                    try {
//                        Thread.sleep(200);
//                    } catch (InterruptedException e) {
//                        e.printStackTrace();
//                    }
//                    main.getContentPane().getComponent(0).repaint();
//                }
//            }
//            
//        }).start();
//    }
//}
